<html>
<head>

</head>

<body>
	<form method="post">
		<select name="country">	
			<option>-</option>
			<?php 
				$country = "";
				if($_POST) {
					$country = $_POST['country'];					
				}
				$countries = array("Bulgaria", 
						           "Italy", 
						           "Germany",
						           "Macedonia");
				
				$cities = array(
							"Bulgaria" => array("Sofia", "Pernik", "Varna"),
							"Italy"    => array("Rome", "Venice", "Milan"),
							"Germany"  => array("Munchen", "Cologne", "Hamburg"),
							"Macedonia"=> array("Ohrid", "Scopie", ""),
							);
				
				
				for($i = 0; $i < count($countries); $i++) {
					$element = $countries[$i];
					if($country == $element){
						echo "<option selected=\"selected\">$element</option>\n";
					} else {			
						echo "<option>$element</option>\n";
					}
					
				}
			?>	
			
		</select>	
		<select name="cities">
			<option>-</option>
			<?php 
				$selectedCity = "";
				if($_POST) {
					$selectedCity = $_POST['cities'];
				}
				if($country != ""){
					$current_cities = $cities[$country];
					foreach($current_cities as $c_city){
						if($selectedCity == $c_city){
								echo "<option selected=\"selected\">$c_city</option>\n";
							} else {
								echo "<option>$c_city</option>\n";
								}
					}
				}
			?>
		</select>
		<input type="submit" value="Send Me!" />
	</form>
</body>
</html>
